package weibo4j;

import weibo4j.model.Paging;
import weibo4j.model.PostParameter;
import weibo4j.model.Status;
import weibo4j.model.StatusWapper;
import weibo4j.model.User;
import weibo4j.model.UserWapper;
import weibo4j.model.WeiboException;
import weibo4j.org.json.JSONArray;
import weibo4j.util.WeiboConfig;

public class Suggestion {
	/**
	 * 
	 * @return list of the users
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/users/hot">suggestions/users/hot</a>
	 * @since JDK 1.5
	 */

	public JSONArray suggestionsUsersHot(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL") + "suggestions/users/hot.json")
				.asJSONArray();
	}

	public JSONArray suggestionsUsersHot(Weibo weibo, String category) throws WeiboException {
		return weibo.getClient()
				.get(WeiboConfig.getValue("baseURL")
						+ "suggestions/users/hot.json",
						new PostParameter[] { new PostParameter("category",
								category) }).asJSONArray();
	}

	/**
	 * 
	 * @return list of the user's id
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/users/may_interested">suggestions/users/may_interested</a>
	 * @since JDK 1.5
	 */
	public JSONArray suggestionsUsersMayInterested(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/users/may_interested.json")
				.asJSONArray();
	}

	public JSONArray suggestionsUsersMayInterested(Weibo weibo, int count, int page)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/users/may_interested.json",
				new PostParameter[] { new PostParameter("count", count),
						new PostParameter("page", page) }).asJSONArray();
	}

	/**
	 * 
	 * @return list of the users
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/users/by_status">suggestions/users/by_status</a>
	 * @since JDK 1.5
	 */
	public UserWapper suggestionsUsersByStatus(Weibo weibo, String content)
			throws WeiboException {
		return User.constructWapperUsers(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/users/by_status.json",
				new PostParameter[] { new PostParameter("content", content) }));
	}

	public UserWapper suggestionsUsersByStatus(Weibo weibo, String content, int num)
			throws WeiboException {
		return User.constructWapperUsers(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/users/by_status.json",
				new PostParameter[] { new PostParameter("content", content),
						new PostParameter("num", num) }));
	}

	/**
	 * 
	 * @return list of the status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/statuses/hot">suggestions/statuses/hot</a>
	 * @since JDK 1.5
	 */
	public StatusWapper suggestionsStatusesHot(Weibo weibo, int type, int isPic)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/statuses/hot.json", new PostParameter[] {
						new PostParameter("type", type),
						new PostParameter("is_pic", isPic) }));
	}

	public StatusWapper suggestionsStatusesHot(Weibo weibo, int type, int isPic, Paging page)
			throws WeiboException {
		return Status.constructWapperStatus(weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/statuses/hot.json", new PostParameter[] {
						new PostParameter("type", type),
						new PostParameter("is_pic", isPic) }, page));
	}

	/**
	 * 
	 * @return list of the status
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/favorites/hot">suggestions/favorites/hot</a>
	 * @since JDK 1.5
	 */
	public JSONArray suggestionsFavoritesHot(Weibo weibo) throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/favorites/hot.json").asJSONArray();
	}

	public JSONArray suggestionsFavoritesHot(Weibo weibo, int page, int count)
			throws WeiboException {
		return weibo.getClient().get(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/favorites/hot.json",
				new PostParameter[] { new PostParameter("page", page),
						new PostParameter("count", count) }).asJSONArray();
	}

	/**
	 * 
	 * @return user
	 * @throws WeiboException
	 *             when Weibo service or network is unavailable
	 * @version weibo4j-V2 1.0.1
	 * @see <a
	 *      href="http://open.weibo.com/wiki/2/suggestions/users/not_interested">suggestions/users/not_interested</a>
	 * @since JDK 1.5
	 */
	public User suggestionsUsersNot_interested(Weibo weibo, String uid)
			throws WeiboException {
		return new User(weibo.getClient().post(
				WeiboConfig.getValue("baseURL")
						+ "suggestions/users/not_interested.json",
				new PostParameter[] { new PostParameter("uid", uid) })
				.asJSONObject());
	}
}
